package page58;

public class Test3 {
    public static void main(String[] args) {
        int n = 20;
        int i = 1, j = 1;
        int temp = 1;
        double sum = 0;
        do {
            do {
                temp *= j;
                j++;
            } while (j <= i);
            sum += 1.0 / temp;
            i++;
        } while (i <= n);
        System.out.println(sum);

        temp = 1;
        sum = 0;
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= i; j++) {
                temp *= j;
            }
            sum += 1.0 / temp;
            temp = 1;
        }
        System.out.println(sum);
    }
}
